{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "    <div class=\"bk-root\">\n",
       "        <a href=\"https://bokeh.org\" target=\"_blank\" class=\"bk-logo bk-logo-small bk-logo-notebook\"></a>\n",
       "        <span id=\"1078\">Loading BokehJS ...</span>\n",
       "    </div>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "application/javascript": [
       "\n",
       "(function(root) {\n",
       "  function now() {\n",
       "    return new Date();\n",
       "  }\n",
       "\n",
       "  var force = true;\n",
       "\n",
       "  if (typeof root._bokeh_onload_callbacks === \"undefined\" || force === true) {\n",
       "    root._bokeh_onload_callbacks = [];\n",
       "    root._bokeh_is_loading = undefined;\n",
       "  }\n",
       "\n",
       "  var JS_MIME_TYPE = 'application/javascript';\n",
       "  var HTML_MIME_TYPE = 'text/html';\n",
       "  var EXEC_MIME_TYPE = 'application/vnd.bokehjs_exec.v0+json';\n",
       "  var CLASS_NAME = 'output_bokeh rendered_html';\n",
       "\n",
       "  /**\n",
       "   * Render data to the DOM node\n",
       "   */\n",
       "  function render(props, node) {\n",
       "    var script = document.createElement(\"script\");\n",
       "    node.appendChild(script);\n",
       "  }\n",
       "\n",
       "  /**\n",
       "   * Handle when an output is cleared or removed\n",
       "   */\n",
       "  function handleClearOutput(event, handle) {\n",
       "    var cell = handle.cell;\n",
       "\n",
       "    var id = cell.output_area._bokeh_element_id;\n",
       "    var server_id = cell.output_area._bokeh_server_id;\n",
       "    // Clean up Bokeh references\n",
       "    if (id != null && id in Bokeh.index) {\n",
       "      Bokeh.index[id].model.document.clear();\n",
       "      delete Bokeh.index[id];\n",
       "    }\n",
       "\n",
       "    if (server_id !== undefined) {\n",
       "      // Clean up Bokeh references\n",
       "      var cmd = \"from bokeh.io.state import curstate; print(curstate().uuid_to_server['\" + server_id + \"'].get_sessions()[0].document.roots[0]._id)\";\n",
       "      cell.notebook.kernel.execute(cmd, {\n",
       "        iopub: {\n",
       "          output: function(msg) {\n",
       "            var id = msg.content.text.trim();\n",
       "            if (id in Bokeh.index) {\n",
       "              Bokeh.index[id].model.document.clear();\n",
       "              delete Bokeh.index[id];\n",
       "            }\n",
       "          }\n",
       "        }\n",
       "      });\n",
       "      // Destroy server and session\n",
       "      var cmd = \"import bokeh.io.notebook as ion; ion.destroy_server('\" + server_id + \"')\";\n",
       "      cell.notebook.kernel.execute(cmd);\n",
       "    }\n",
       "  }\n",
       "\n",
       "  /**\n",
       "   * Handle when a new output is added\n",
       "   */\n",
       "  function handleAddOutput(event, handle) {\n",
       "    var output_area = handle.output_area;\n",
       "    var output = handle.output;\n",
       "\n",
       "    // limit handleAddOutput to display_data with EXEC_MIME_TYPE content only\n",
       "    if ((output.output_type != \"display_data\") || (!output.data.hasOwnProperty(EXEC_MIME_TYPE))) {\n",
       "      return\n",
       "    }\n",
       "\n",
       "    var toinsert = output_area.element.find(\".\" + CLASS_NAME.split(' ')[0]);\n",
       "\n",
       "    if (output.metadata[EXEC_MIME_TYPE][\"id\"] !== undefined) {\n",
       "      toinsert[toinsert.length - 1].firstChild.textContent = output.data[JS_MIME_TYPE];\n",
       "      // store reference to embed id on output_area\n",
       "      output_area._bokeh_element_id = output.metadata[EXEC_MIME_TYPE][\"id\"];\n",
       "    }\n",
       "    if (output.metadata[EXEC_MIME_TYPE][\"server_id\"] !== undefined) {\n",
       "      var bk_div = document.createElement(\"div\");\n",
       "      bk_div.innerHTML = output.data[HTML_MIME_TYPE];\n",
       "      var script_attrs = bk_div.children[0].attributes;\n",
       "      for (var i = 0; i < script_attrs.length; i++) {\n",
       "        toinsert[toinsert.length - 1].firstChild.setAttribute(script_attrs[i].name, script_attrs[i].value);\n",
       "        toinsert[toinsert.length - 1].firstChild.textContent = bk_div.children[0].textContent\n",
       "      }\n",
       "      // store reference to server id on output_area\n",
       "      output_area._bokeh_server_id = output.metadata[EXEC_MIME_TYPE][\"server_id\"];\n",
       "    }\n",
       "  }\n",
       "\n",
       "  function register_renderer(events, OutputArea) {\n",
       "\n",
       "    function append_mime(data, metadata, element) {\n",
       "      // create a DOM node to render to\n",
       "      var toinsert = this.create_output_subarea(\n",
       "        metadata,\n",
       "        CLASS_NAME,\n",
       "        EXEC_MIME_TYPE\n",
       "      );\n",
       "      this.keyboard_manager.register_events(toinsert);\n",
       "      // Render to node\n",
       "      var props = {data: data, metadata: metadata[EXEC_MIME_TYPE]};\n",
       "      render(props, toinsert[toinsert.length - 1]);\n",
       "      element.append(toinsert);\n",
       "      return toinsert\n",
       "    }\n",
       "\n",
       "    /* Handle when an output is cleared or removed */\n",
       "    events.on('clear_output.CodeCell', handleClearOutput);\n",
       "    events.on('delete.Cell', handleClearOutput);\n",
       "\n",
       "    /* Handle when a new output is added */\n",
       "    events.on('output_added.OutputArea', handleAddOutput);\n",
       "\n",
       "    /**\n",
       "     * Register the mime type and append_mime function with output_area\n",
       "     */\n",
       "    OutputArea.prototype.register_mime_type(EXEC_MIME_TYPE, append_mime, {\n",
       "      /* Is output safe? */\n",
       "      safe: true,\n",
       "      /* Index of renderer in `output_area.display_order` */\n",
       "      index: 0\n",
       "    });\n",
       "  }\n",
       "\n",
       "  // register the mime type if in Jupyter Notebook environment and previously unregistered\n",
       "  if (root.Jupyter !== undefined) {\n",
       "    var events = require('base/js/events');\n",
       "    var OutputArea = require('notebook/js/outputarea').OutputArea;\n",
       "\n",
       "    if (OutputArea.prototype.mime_types().indexOf(EXEC_MIME_TYPE) == -1) {\n",
       "      register_renderer(events, OutputArea);\n",
       "    }\n",
       "  }\n",
       "\n",
       "  \n",
       "  if (typeof (root._bokeh_timeout) === \"undefined\" || force === true) {\n",
       "    root._bokeh_timeout = Date.now() + 5000;\n",
       "    root._bokeh_failed_load = false;\n",
       "  }\n",
       "\n",
       "  var NB_LOAD_WARNING = {'data': {'text/html':\n",
       "     \"<div style='background-color: #fdd'>\\n\"+\n",
       "     \"<p>\\n\"+\n",
       "     \"BokehJS does not appear to have successfully loaded. If loading BokehJS from CDN, this \\n\"+\n",
       "     \"may be due to a slow or bad network connection. Possible fixes:\\n\"+\n",
       "     \"</p>\\n\"+\n",
       "     \"<ul>\\n\"+\n",
       "     \"<li>re-rerun `output_notebook()` to attempt to load from CDN again, or</li>\\n\"+\n",
       "     \"<li>use INLINE resources instead, as so:</li>\\n\"+\n",
       "     \"</ul>\\n\"+\n",
       "     \"<code>\\n\"+\n",
       "     \"from bokeh.resources import INLINE\\n\"+\n",
       "     \"output_notebook(resources=INLINE)\\n\"+\n",
       "     \"</code>\\n\"+\n",
       "     \"</div>\"}};\n",
       "\n",
       "  function display_loaded() {\n",
       "    var el = document.getElementById(\"1078\");\n",
       "    if (el != null) {\n",
       "      el.textContent = \"BokehJS is loading...\";\n",
       "    }\n",
       "    if (root.Bokeh !== undefined) {\n",
       "      if (el != null) {\n",
       "        el.textContent = \"BokehJS \" + root.Bokeh.version + \" successfully loaded.\";\n",
       "      }\n",
       "    } else if (Date.now() < root._bokeh_timeout) {\n",
       "      setTimeout(display_loaded, 100)\n",
       "    }\n",
       "  }\n",
       "\n",
       "\n",
       "  function run_callbacks() {\n",
       "    try {\n",
       "      root._bokeh_onload_callbacks.forEach(function(callback) {\n",
       "        if (callback != null)\n",
       "          callback();\n",
       "      });\n",
       "    } finally {\n",
       "      delete root._bokeh_onload_callbacks\n",
       "    }\n",
       "    console.debug(\"Bokeh: all callbacks have finished\");\n",
       "  }\n",
       "\n",
       "  function load_libs(css_urls, js_urls, callback) {\n",
       "    if (css_urls == null) css_urls = [];\n",
       "    if (js_urls == null) js_urls = [];\n",
       "\n",
       "    root._bokeh_onload_callbacks.push(callback);\n",
       "    if (root._bokeh_is_loading > 0) {\n",
       "      console.debug(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n",
       "      return null;\n",
       "    }\n",
       "    if (js_urls == null || js_urls.length === 0) {\n",
       "      run_callbacks();\n",
       "      return null;\n",
       "    }\n",
       "    console.debug(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n",
       "    root._bokeh_is_loading = css_urls.length + js_urls.length;\n",
       "\n",
       "    function on_load() {\n",
       "      root._bokeh_is_loading--;\n",
       "      if (root._bokeh_is_loading === 0) {\n",
       "        console.debug(\"Bokeh: all BokehJS libraries/stylesheets loaded\");\n",
       "        run_callbacks()\n",
       "      }\n",
       "    }\n",
       "\n",
       "    function on_error() {\n",
       "      console.error(\"failed to load \" + url);\n",
       "    }\n",
       "\n",
       "    for (var i = 0; i < css_urls.length; i++) {\n",
       "      var url = css_urls[i];\n",
       "      const element = document.createElement(\"link\");\n",
       "      element.onload = on_load;\n",
       "      element.onerror = on_error;\n",
       "      element.rel = \"stylesheet\";\n",
       "      element.type = \"text/css\";\n",
       "      element.href = url;\n",
       "      console.debug(\"Bokeh: injecting link tag for BokehJS stylesheet: \", url);\n",
       "      document.body.appendChild(element);\n",
       "    }\n",
       "\n",
       "    const hashes = {\"https://cdn.bokeh.org/bokeh/release/bokeh-2.1.1.min.js\": \"kLr4fYcqcSpbuI95brIH3vnnYCquzzSxHPU6XGQCIkQRGJwhg0StNbj1eegrHs12\", \"https://cdn.bokeh.org/bokeh/release/bokeh-widgets-2.1.1.min.js\": \"xIGPmVtaOm+z0BqfSOMn4lOR6ciex448GIKG4eE61LsAvmGj48XcMQZtKcE/UXZe\", \"https://cdn.bokeh.org/bokeh/release/bokeh-tables-2.1.1.min.js\": \"Dc9u1wF/0zApGIWoBbH77iWEHtdmkuYWG839Uzmv8y8yBLXebjO9ZnERsde5Ln/P\", \"https://cdn.bokeh.org/bokeh/release/bokeh-gl-2.1.1.min.js\": \"cT9JaBz7GiRXdENrJLZNSC6eMNF3nh3fa5fTF51Svp+ukxPdwcU5kGXGPBgDCa2j\"};\n",
       "\n",
       "    for (var i = 0; i < js_urls.length; i++) {\n",
       "      var url = js_urls[i];\n",
       "      var element = document.createElement('script');\n",
       "      element.onload = on_load;\n",
       "      element.onerror = on_error;\n",
       "      element.async = false;\n",
       "      element.src = url;\n",
       "      if (url in hashes) {\n",
       "        element.crossOrigin = \"anonymous\";\n",
       "        element.integrity = \"sha384-\" + hashes[url];\n",
       "      }\n",
       "      console.debug(\"Bokeh: injecting script tag for BokehJS library: \", url);\n",
       "      document.head.appendChild(element);\n",
       "    }\n",
       "  };\n",
       "\n",
       "  function inject_raw_css(css) {\n",
       "    const element = document.createElement(\"style\");\n",
       "    element.appendChild(document.createTextNode(css));\n",
       "    document.body.appendChild(element);\n",
       "  }\n",
       "\n",
       "  \n",
       "  var js_urls = [\"https://cdn.bokeh.org/bokeh/release/bokeh-2.1.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-widgets-2.1.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-tables-2.1.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-gl-2.1.1.min.js\"];\n",
       "  var css_urls = [];\n",
       "  \n",
       "\n",
       "  var inline_js = [\n",
       "    function(Bokeh) {\n",
       "      Bokeh.set_log_level(\"info\");\n",
       "    },\n",
       "    function(Bokeh) {\n",
       "    \n",
       "    \n",
       "    }\n",
       "  ];\n",
       "\n",
       "  function run_inline_js() {\n",
       "    \n",
       "    if (root.Bokeh !== undefined || force === true) {\n",
       "      \n",
       "    for (var i = 0; i < inline_js.length; i++) {\n",
       "      inline_js[i].call(root, root.Bokeh);\n",
       "    }\n",
       "    if (force === true) {\n",
       "        display_loaded();\n",
       "      }} else if (Date.now() < root._bokeh_timeout) {\n",
       "      setTimeout(run_inline_js, 100);\n",
       "    } else if (!root._bokeh_failed_load) {\n",
       "      console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n",
       "      root._bokeh_failed_load = true;\n",
       "    } else if (force !== true) {\n",
       "      var cell = $(document.getElementById(\"1078\")).parents('.cell').data().cell;\n",
       "      cell.output_area.append_execute_result(NB_LOAD_WARNING)\n",
       "    }\n",
       "\n",
       "  }\n",
       "\n",
       "  if (root._bokeh_is_loading === 0) {\n",
       "    console.debug(\"Bokeh: BokehJS loaded, going straight to plotting\");\n",
       "    run_inline_js();\n",
       "  } else {\n",
       "    load_libs(css_urls, js_urls, function() {\n",
       "      console.debug(\"Bokeh: BokehJS plotting callback run at\", now());\n",
       "      run_inline_js();\n",
       "    });\n",
       "  }\n",
       "}(window));"
      ],
      "application/vnd.bokehjs_load.v0+json": "\n(function(root) {\n  function now() {\n    return new Date();\n  }\n\n  var force = true;\n\n  if (typeof root._bokeh_onload_callbacks === \"undefined\" || force === true) {\n    root._bokeh_onload_callbacks = [];\n    root._bokeh_is_loading = undefined;\n  }\n\n  \n\n  \n  if (typeof (root._bokeh_timeout) === \"undefined\" || force === true) {\n    root._bokeh_timeout = Date.now() + 5000;\n    root._bokeh_failed_load = false;\n  }\n\n  var NB_LOAD_WARNING = {'data': {'text/html':\n     \"<div style='background-color: #fdd'>\\n\"+\n     \"<p>\\n\"+\n     \"BokehJS does not appear to have successfully loaded. If loading BokehJS from CDN, this \\n\"+\n     \"may be due to a slow or bad network connection. Possible fixes:\\n\"+\n     \"</p>\\n\"+\n     \"<ul>\\n\"+\n     \"<li>re-rerun `output_notebook()` to attempt to load from CDN again, or</li>\\n\"+\n     \"<li>use INLINE resources instead, as so:</li>\\n\"+\n     \"</ul>\\n\"+\n     \"<code>\\n\"+\n     \"from bokeh.resources import INLINE\\n\"+\n     \"output_notebook(resources=INLINE)\\n\"+\n     \"</code>\\n\"+\n     \"</div>\"}};\n\n  function display_loaded() {\n    var el = document.getElementById(\"1078\");\n    if (el != null) {\n      el.textContent = \"BokehJS is loading...\";\n    }\n    if (root.Bokeh !== undefined) {\n      if (el != null) {\n        el.textContent = \"BokehJS \" + root.Bokeh.version + \" successfully loaded.\";\n      }\n    } else if (Date.now() < root._bokeh_timeout) {\n      setTimeout(display_loaded, 100)\n    }\n  }\n\n\n  function run_callbacks() {\n    try {\n      root._bokeh_onload_callbacks.forEach(function(callback) {\n        if (callback != null)\n          callback();\n      });\n    } finally {\n      delete root._bokeh_onload_callbacks\n    }\n    console.debug(\"Bokeh: all callbacks have finished\");\n  }\n\n  function load_libs(css_urls, js_urls, callback) {\n    if (css_urls == null) css_urls = [];\n    if (js_urls == null) js_urls = [];\n\n    root._bokeh_onload_callbacks.push(callback);\n    if (root._bokeh_is_loading > 0) {\n      console.debug(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n      return null;\n    }\n    if (js_urls == null || js_urls.length === 0) {\n      run_callbacks();\n      return null;\n    }\n    console.debug(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n    root._bokeh_is_loading = css_urls.length + js_urls.length;\n\n    function on_load() {\n      root._bokeh_is_loading--;\n      if (root._bokeh_is_loading === 0) {\n        console.debug(\"Bokeh: all BokehJS libraries/stylesheets loaded\");\n        run_callbacks()\n      }\n    }\n\n    function on_error() {\n      console.error(\"failed to load \" + url);\n    }\n\n    for (var i = 0; i < css_urls.length; i++) {\n      var url = css_urls[i];\n      const element = document.createElement(\"link\");\n      element.onload = on_load;\n      element.onerror = on_error;\n      element.rel = \"stylesheet\";\n      element.type = \"text/css\";\n      element.href = url;\n      console.debug(\"Bokeh: injecting link tag for BokehJS stylesheet: \", url);\n      document.body.appendChild(element);\n    }\n\n    const hashes = {\"https://cdn.bokeh.org/bokeh/release/bokeh-2.1.1.min.js\": \"kLr4fYcqcSpbuI95brIH3vnnYCquzzSxHPU6XGQCIkQRGJwhg0StNbj1eegrHs12\", \"https://cdn.bokeh.org/bokeh/release/bokeh-widgets-2.1.1.min.js\": \"xIGPmVtaOm+z0BqfSOMn4lOR6ciex448GIKG4eE61LsAvmGj48XcMQZtKcE/UXZe\", \"https://cdn.bokeh.org/bokeh/release/bokeh-tables-2.1.1.min.js\": \"Dc9u1wF/0zApGIWoBbH77iWEHtdmkuYWG839Uzmv8y8yBLXebjO9ZnERsde5Ln/P\", \"https://cdn.bokeh.org/bokeh/release/bokeh-gl-2.1.1.min.js\": \"cT9JaBz7GiRXdENrJLZNSC6eMNF3nh3fa5fTF51Svp+ukxPdwcU5kGXGPBgDCa2j\"};\n\n    for (var i = 0; i < js_urls.length; i++) {\n      var url = js_urls[i];\n      var element = document.createElement('script');\n      element.onload = on_load;\n      element.onerror = on_error;\n      element.async = false;\n      element.src = url;\n      if (url in hashes) {\n        element.crossOrigin = \"anonymous\";\n        element.integrity = \"sha384-\" + hashes[url];\n      }\n      console.debug(\"Bokeh: injecting script tag for BokehJS library: \", url);\n      document.head.appendChild(element);\n    }\n  };\n\n  function inject_raw_css(css) {\n    const element = document.createElement(\"style\");\n    element.appendChild(document.createTextNode(css));\n    document.body.appendChild(element);\n  }\n\n  \n  var js_urls = [\"https://cdn.bokeh.org/bokeh/release/bokeh-2.1.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-widgets-2.1.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-tables-2.1.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-gl-2.1.1.min.js\"];\n  var css_urls = [];\n  \n\n  var inline_js = [\n    function(Bokeh) {\n      Bokeh.set_log_level(\"info\");\n    },\n    function(Bokeh) {\n    \n    \n    }\n  ];\n\n  function run_inline_js() {\n    \n    if (root.Bokeh !== undefined || force === true) {\n      \n    for (var i = 0; i < inline_js.length; i++) {\n      inline_js[i].call(root, root.Bokeh);\n    }\n    if (force === true) {\n        display_loaded();\n      }} else if (Date.now() < root._bokeh_timeout) {\n      setTimeout(run_inline_js, 100);\n    } else if (!root._bokeh_failed_load) {\n      console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n      root._bokeh_failed_load = true;\n    } else if (force !== true) {\n      var cell = $(document.getElementById(\"1078\")).parents('.cell').data().cell;\n      cell.output_area.append_execute_result(NB_LOAD_WARNING)\n    }\n\n  }\n\n  if (root._bokeh_is_loading === 0) {\n    console.debug(\"Bokeh: BokehJS loaded, going straight to plotting\");\n    run_inline_js();\n  } else {\n    load_libs(css_urls, js_urls, function() {\n      console.debug(\"Bokeh: BokehJS plotting callback run at\", now());\n      run_inline_js();\n    });\n  }\n}(window));"
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "from bokeh.plotting import output_notebook,figure,show\n",
    "output_notebook()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 数据准备模块\n",
    "from bokeh.models import ColumnDataSource\n",
    "from bokeh.palettes import Spectral5\n",
    "from bokeh.core.properties import value\n",
    "from bokeh.palettes import Spectral3"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 数据准备\n",
    "fruits = ['Apples', 'Pears', 'Nectarines', 'Plums', 'Grapes', 'Strawberries']\n",
    "years = [\"2015\",\"2016\",\"2017\"]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 堆叠数据\n",
    "data = {'fruits' :  ['Apples', 'Pears', 'Nectarines', 'Plums', 'Grapes', 'Strawberries'],\n",
    "        '2015'   : [2, 1, 4, 3, 2, 4],\n",
    "        '2016'   : [5, 3, 4, 2, 4, 6],\n",
    "        '2017'   : [3, 2, 4, 4, 5, 3]}\n",
    "# 颜色的准备\n",
    "colors = Spectral3"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "BokehDeprecationWarning: 'legend' keyword is deprecated, use explicit 'legend_label', 'legend_field', or 'legend_group' keywords instead\n",
      "BokehDeprecationWarning: 'legend' keyword is deprecated, use explicit 'legend_label', 'legend_field', or 'legend_group' keywords instead\n",
      "BokehDeprecationWarning: 'legend' keyword is deprecated, use explicit 'legend_label', 'legend_field', or 'legend_group' keywords instead\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "\n",
       "\n",
       "\n",
       "\n",
       "\n",
       "\n",
       "  <div class=\"bk-root\" id=\"545a6102-9546-4a71-b1b4-dd5f9007573f\" data-root-id=\"1205\"></div>\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "application/javascript": [
       "(function(root) {\n",
       "  function embed_document(root) {\n",
       "    \n",
       "  var docs_json = {\"6014add3-bd07-4e08-b789-6418b2883fd8\":{\"roots\":{\"references\":[{\"attributes\":{\"below\":[{\"id\":\"1216\"}],\"center\":[{\"id\":\"1218\"},{\"id\":\"1222\"},{\"id\":\"1258\"}],\"left\":[{\"id\":\"1219\"}],\"plot_height\":300,\"renderers\":[{\"id\":\"1248\"},{\"id\":\"1263\"},{\"id\":\"1277\"}],\"title\":{\"id\":\"1206\"},\"toolbar\":{\"id\":\"1231\"},\"x_range\":{\"id\":\"1208\"},\"x_scale\":{\"id\":\"1212\"},\"y_range\":{\"id\":\"1210\"},\"y_scale\":{\"id\":\"1214\"}},\"id\":\"1205\",\"subtype\":\"Figure\",\"type\":\"Plot\"},{\"attributes\":{},\"id\":\"1212\",\"type\":\"CategoricalScale\"},{\"attributes\":{\"bottom\":{\"expr\":{\"id\":\"1239\"}},\"fill_color\":{\"value\":\"#99d594\"},\"line_color\":{\"value\":\"#99d594\"},\"top\":{\"expr\":{\"id\":\"1240\"}},\"width\":{\"value\":0.8},\"x\":{\"field\":\"fruits\"}},\"id\":\"1246\",\"type\":\"VBar\"},{\"attributes\":{},\"id\":\"1224\",\"type\":\"WheelZoomTool\"},{\"attributes\":{\"data_source\":{\"id\":\"1204\"},\"glyph\":{\"id\":\"1261\"},\"hover_glyph\":null,\"muted_glyph\":null,\"name\":\"2016\",\"nonselection_glyph\":{\"id\":\"1262\"},\"selection_glyph\":null,\"view\":{\"id\":\"1264\"}},\"id\":\"1263\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"bottom\":{\"expr\":{\"id\":\"1243\"}},\"fill_color\":{\"value\":\"#fc8d59\"},\"line_color\":{\"value\":\"#fc8d59\"},\"top\":{\"expr\":{\"id\":\"1244\"}},\"width\":{\"value\":0.8},\"x\":{\"field\":\"fruits\"}},\"id\":\"1275\",\"type\":\"VBar\"},{\"attributes\":{},\"id\":\"1223\",\"type\":\"PanTool\"},{\"attributes\":{\"formatter\":{\"id\":\"1251\"},\"ticker\":{\"id\":\"1217\"}},\"id\":\"1216\",\"type\":\"CategoricalAxis\"},{\"attributes\":{\"source\":{\"id\":\"1204\"}},\"id\":\"1278\",\"type\":\"CDSView\"},{\"attributes\":{},\"id\":\"1210\",\"type\":\"DataRange1d\"},{\"attributes\":{\"fields\":[\"2015\",\"2016\",\"2017\"]},\"id\":\"1244\",\"type\":\"Stack\"},{\"attributes\":{\"fields\":[\"2015\",\"2016\"]},\"id\":\"1243\",\"type\":\"Stack\"},{\"attributes\":{},\"id\":\"1226\",\"type\":\"SaveTool\"},{\"attributes\":{\"factors\":[\"Apples\",\"Pears\",\"Nectarines\",\"Plums\",\"Grapes\",\"Strawberries\"]},\"id\":\"1208\",\"type\":\"FactorRange\"},{\"attributes\":{\"label\":{\"value\":\"2017\"},\"renderers\":[{\"id\":\"1277\"}]},\"id\":\"1287\",\"type\":\"LegendItem\"},{\"attributes\":{\"bottom\":{\"expr\":{\"id\":\"1239\"}},\"fill_alpha\":{\"value\":0.1},\"fill_color\":{\"value\":\"#99d594\"},\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"#99d594\"},\"top\":{\"expr\":{\"id\":\"1240\"}},\"width\":{\"value\":0.8},\"x\":{\"field\":\"fruits\"}},\"id\":\"1247\",\"type\":\"VBar\"},{\"attributes\":{\"bottom\":{\"expr\":{\"id\":\"1243\"}},\"fill_alpha\":{\"value\":0.1},\"fill_color\":{\"value\":\"#fc8d59\"},\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"#fc8d59\"},\"top\":{\"expr\":{\"id\":\"1244\"}},\"width\":{\"value\":0.8},\"x\":{\"field\":\"fruits\"}},\"id\":\"1276\",\"type\":\"VBar\"},{\"attributes\":{},\"id\":\"1251\",\"type\":\"CategoricalTickFormatter\"},{\"attributes\":{\"data_source\":{\"id\":\"1204\"},\"glyph\":{\"id\":\"1275\"},\"hover_glyph\":null,\"muted_glyph\":null,\"name\":\"2017\",\"nonselection_glyph\":{\"id\":\"1276\"},\"selection_glyph\":null,\"view\":{\"id\":\"1278\"}},\"id\":\"1277\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"data\":{\"2015\":[2,1,4,3,2,4],\"2016\":[5,3,4,2,4,6],\"2017\":[3,2,4,4,5,3],\"fruits\":[\"Apples\",\"Pears\",\"Nectarines\",\"Plums\",\"Grapes\",\"Strawberries\"]},\"selected\":{\"id\":\"1257\"},\"selection_policy\":{\"id\":\"1256\"}},\"id\":\"1204\",\"type\":\"ColumnDataSource\"},{\"attributes\":{\"axis\":{\"id\":\"1219\"},\"dimension\":1,\"ticker\":null},\"id\":\"1222\",\"type\":\"Grid\"},{\"attributes\":{\"fields\":[]},\"id\":\"1239\",\"type\":\"Stack\"},{\"attributes\":{\"callback\":null,\"tooltips\":\"$name @fruits: @$name\"},\"id\":\"1230\",\"type\":\"HoverTool\"},{\"attributes\":{\"items\":[{\"id\":\"1259\"},{\"id\":\"1273\"},{\"id\":\"1287\"}]},\"id\":\"1258\",\"type\":\"Legend\"},{\"attributes\":{\"source\":{\"id\":\"1204\"}},\"id\":\"1264\",\"type\":\"CDSView\"},{\"attributes\":{\"text\":\"Fruits Count by Year\"},\"id\":\"1206\",\"type\":\"Title\"},{\"attributes\":{\"fields\":[\"2015\",\"2016\"]},\"id\":\"1242\",\"type\":\"Stack\"},{\"attributes\":{\"label\":{\"value\":\"2016\"},\"renderers\":[{\"id\":\"1263\"}]},\"id\":\"1273\",\"type\":\"LegendItem\"},{\"attributes\":{\"bottom\":{\"expr\":{\"id\":\"1241\"}},\"fill_color\":{\"value\":\"#ffffbf\"},\"line_color\":{\"value\":\"#ffffbf\"},\"top\":{\"expr\":{\"id\":\"1242\"}},\"width\":{\"value\":0.8},\"x\":{\"field\":\"fruits\"}},\"id\":\"1261\",\"type\":\"VBar\"},{\"attributes\":{\"fields\":[\"2015\"]},\"id\":\"1241\",\"type\":\"Stack\"},{\"attributes\":{\"overlay\":{\"id\":\"1229\"}},\"id\":\"1225\",\"type\":\"BoxZoomTool\"},{\"attributes\":{\"fields\":[\"2015\"]},\"id\":\"1240\",\"type\":\"Stack\"},{\"attributes\":{\"bottom\":{\"expr\":{\"id\":\"1241\"}},\"fill_alpha\":{\"value\":0.1},\"fill_color\":{\"value\":\"#ffffbf\"},\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"#ffffbf\"},\"top\":{\"expr\":{\"id\":\"1242\"}},\"width\":{\"value\":0.8},\"x\":{\"field\":\"fruits\"}},\"id\":\"1262\",\"type\":\"VBar\"},{\"attributes\":{\"formatter\":{\"id\":\"1253\"},\"ticker\":{\"id\":\"1220\"}},\"id\":\"1219\",\"type\":\"LinearAxis\"},{\"attributes\":{},\"id\":\"1220\",\"type\":\"BasicTicker\"},{\"attributes\":{},\"id\":\"1228\",\"type\":\"HelpTool\"},{\"attributes\":{\"source\":{\"id\":\"1204\"}},\"id\":\"1249\",\"type\":\"CDSView\"},{\"attributes\":{\"bottom_units\":\"screen\",\"fill_alpha\":0.5,\"fill_color\":\"lightgrey\",\"left_units\":\"screen\",\"level\":\"overlay\",\"line_alpha\":1.0,\"line_color\":\"black\",\"line_dash\":[4,4],\"line_width\":2,\"right_units\":\"screen\",\"top_units\":\"screen\"},\"id\":\"1229\",\"type\":\"BoxAnnotation\"},{\"attributes\":{\"active_drag\":\"auto\",\"active_inspect\":\"auto\",\"active_multi\":null,\"active_scroll\":\"auto\",\"active_tap\":\"auto\",\"tools\":[{\"id\":\"1223\"},{\"id\":\"1224\"},{\"id\":\"1225\"},{\"id\":\"1226\"},{\"id\":\"1227\"},{\"id\":\"1228\"},{\"id\":\"1230\"}]},\"id\":\"1231\",\"type\":\"Toolbar\"},{\"attributes\":{},\"id\":\"1217\",\"type\":\"CategoricalTicker\"},{\"attributes\":{},\"id\":\"1227\",\"type\":\"ResetTool\"},{\"attributes\":{},\"id\":\"1256\",\"type\":\"UnionRenderers\"},{\"attributes\":{\"axis\":{\"id\":\"1216\"},\"ticker\":null},\"id\":\"1218\",\"type\":\"Grid\"},{\"attributes\":{},\"id\":\"1257\",\"type\":\"Selection\"},{\"attributes\":{\"label\":{\"value\":\"2015\"},\"renderers\":[{\"id\":\"1248\"}]},\"id\":\"1259\",\"type\":\"LegendItem\"},{\"attributes\":{},\"id\":\"1253\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{},\"id\":\"1214\",\"type\":\"LinearScale\"},{\"attributes\":{\"data_source\":{\"id\":\"1204\"},\"glyph\":{\"id\":\"1246\"},\"hover_glyph\":null,\"muted_glyph\":null,\"name\":\"2015\",\"nonselection_glyph\":{\"id\":\"1247\"},\"selection_glyph\":null,\"view\":{\"id\":\"1249\"}},\"id\":\"1248\",\"type\":\"GlyphRenderer\"}],\"root_ids\":[\"1205\"]},\"title\":\"Bokeh Application\",\"version\":\"2.1.1\"}};\n",
       "  var render_items = [{\"docid\":\"6014add3-bd07-4e08-b789-6418b2883fd8\",\"root_ids\":[\"1205\"],\"roots\":{\"1205\":\"545a6102-9546-4a71-b1b4-dd5f9007573f\"}}];\n",
       "  root.Bokeh.embed.embed_items_notebook(docs_json, render_items);\n",
       "\n",
       "  }\n",
       "  if (root.Bokeh !== undefined) {\n",
       "    embed_document(root);\n",
       "  } else {\n",
       "    var attempts = 0;\n",
       "    var timer = setInterval(function(root) {\n",
       "      if (root.Bokeh !== undefined) {\n",
       "        clearInterval(timer);\n",
       "        embed_document(root);\n",
       "      } else {\n",
       "        attempts++;\n",
       "        if (attempts > 100) {\n",
       "          clearInterval(timer);\n",
       "          console.log(\"Bokeh: ERROR: Unable to run BokehJS code because BokehJS library is missing\");\n",
       "        }\n",
       "      }\n",
       "    }, 10, root)\n",
       "  }\n",
       "})(window);"
      ],
      "application/vnd.bokehjs_exec.v0+json": ""
     },
     "metadata": {
      "application/vnd.bokehjs_exec.v0+json": {
       "id": "1205"
      }
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "source = ColumnDataSource(\n",
    "    data=data\n",
    ")\n",
    "\n",
    "# 点击的交互式数据\n",
    "TOOLTIPS = [\n",
    "#    (\"标题\",\"数据\")\n",
    "    (\"$name\",\"@fruits:@$name\")\n",
    "]\n",
    "\n",
    "# 画布\n",
    "p = figure(\n",
    "    x_range=fruits,\n",
    "    plot_height = 300,\n",
    "    title=\"Fruits Count by Year\",\n",
    "    tooltips=\"$name @fruits: @$name\"\n",
    "\n",
    ")\n",
    "\n",
    "# 绘图（vbar_stack）\n",
    "p.vbar_stack(\n",
    "    years,\n",
    "    x='fruits',\n",
    "    width=0.8,\n",
    "    color = colors,\n",
    "    source=source,\n",
    "    legend=[value(x) for x in years]\n",
    "\n",
    ")\n",
    "\n",
    "\n",
    "\n",
    "show(p)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 按照如下要求绘制上述DEMO堆叠柱状图（本节实践，期中考核）\n",
    "* 1.筛选数据：居民人均可支配收入累计值（元）\n",
    "* 2.堆叠：5个季度的时间顺序\n",
    "* 3.x轴：地区"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>指标</th>\n",
       "      <th>2022年第一季度</th>\n",
       "      <th>2021年第四季度</th>\n",
       "      <th>2021年第三季度</th>\n",
       "      <th>2021年第二季度</th>\n",
       "      <th>2021年第一季度</th>\n",
       "      <th>地区</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>居民人均可支配收入累计值(元)</td>\n",
       "      <td>13360</td>\n",
       "      <td>44993</td>\n",
       "      <td>35694</td>\n",
       "      <td>23604</td>\n",
       "      <td>12636</td>\n",
       "      <td>广东省</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>城镇居民人均可支配收入累计值(元)</td>\n",
       "      <td>16230</td>\n",
       "      <td>54854</td>\n",
       "      <td>43592</td>\n",
       "      <td>28897</td>\n",
       "      <td>15472</td>\n",
       "      <td>广东省</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>农村居民人均可支配收入累计值(元)</td>\n",
       "      <td>6639</td>\n",
       "      <td>22306</td>\n",
       "      <td>17619</td>\n",
       "      <td>11490</td>\n",
       "      <td>6225</td>\n",
       "      <td>广东省</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>居民人均可支配收入累计值(元)</td>\n",
       "      <td>20630</td>\n",
       "      <td>75002</td>\n",
       "      <td>56498</td>\n",
       "      <td>38138</td>\n",
       "      <td>19585</td>\n",
       "      <td>北京</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>城镇居民人均可支配收入累计值(元)</td>\n",
       "      <td>22274</td>\n",
       "      <td>81518</td>\n",
       "      <td>61243</td>\n",
       "      <td>41381</td>\n",
       "      <td>21189</td>\n",
       "      <td>北京</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>农村居民人均可支配收入累计值(元)</td>\n",
       "      <td>10016</td>\n",
       "      <td>33303</td>\n",
       "      <td>26125</td>\n",
       "      <td>17383</td>\n",
       "      <td>9326</td>\n",
       "      <td>北京</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>居民人均可支配收入累计值(元)</td>\n",
       "      <td>22663</td>\n",
       "      <td>78027</td>\n",
       "      <td>58907</td>\n",
       "      <td>40357</td>\n",
       "      <td>21548</td>\n",
       "      <td>上海市</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>城镇居民人均可支配收入累计值(元)</td>\n",
       "      <td>23772</td>\n",
       "      <td>82429</td>\n",
       "      <td>61915</td>\n",
       "      <td>42348</td>\n",
       "      <td>22636</td>\n",
       "      <td>上海市</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>农村居民人均可支配收入累计值(元)</td>\n",
       "      <td>12891</td>\n",
       "      <td>38521</td>\n",
       "      <td>31985</td>\n",
       "      <td>22535</td>\n",
       "      <td>12006</td>\n",
       "      <td>上海市</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>居民人均可支配收入累计值(元)</td>\n",
       "      <td>19366</td>\n",
       "      <td>57541</td>\n",
       "      <td>44712</td>\n",
       "      <td>30998</td>\n",
       "      <td>18263</td>\n",
       "      <td>浙江省</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>城镇居民人均可支配收入累计值(元)</td>\n",
       "      <td>22784</td>\n",
       "      <td>68487</td>\n",
       "      <td>52758</td>\n",
       "      <td>36294</td>\n",
       "      <td>21600</td>\n",
       "      <td>浙江省</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>农村居民人均可支配收入累计值(元)</td>\n",
       "      <td>12541</td>\n",
       "      <td>35247</td>\n",
       "      <td>28474</td>\n",
       "      <td>20357</td>\n",
       "      <td>11686</td>\n",
       "      <td>浙江省</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>居民人均可支配收入累计值(元)</td>\n",
       "      <td>16490</td>\n",
       "      <td>47498</td>\n",
       "      <td>36227</td>\n",
       "      <td>25119</td>\n",
       "      <td>15500</td>\n",
       "      <td>江苏省</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>城镇居民人均可支配收入累计值(元)</td>\n",
       "      <td>19251</td>\n",
       "      <td>57743</td>\n",
       "      <td>44267</td>\n",
       "      <td>30491</td>\n",
       "      <td>18194</td>\n",
       "      <td>江苏省</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>农村居民人均可支配收入累计值(元)</td>\n",
       "      <td>10952</td>\n",
       "      <td>26791</td>\n",
       "      <td>20267</td>\n",
       "      <td>14455</td>\n",
       "      <td>10215</td>\n",
       "      <td>江苏省</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                   指标  2022年第一季度  2021年第四季度  2021年第三季度  2021年第二季度  2021年第一季度  \\\n",
       "0     居民人均可支配收入累计值(元)      13360      44993      35694      23604      12636   \n",
       "1   城镇居民人均可支配收入累计值(元)      16230      54854      43592      28897      15472   \n",
       "2   农村居民人均可支配收入累计值(元)       6639      22306      17619      11490       6225   \n",
       "3     居民人均可支配收入累计值(元)      20630      75002      56498      38138      19585   \n",
       "4   城镇居民人均可支配收入累计值(元)      22274      81518      61243      41381      21189   \n",
       "5   农村居民人均可支配收入累计值(元)      10016      33303      26125      17383       9326   \n",
       "6     居民人均可支配收入累计值(元)      22663      78027      58907      40357      21548   \n",
       "7   城镇居民人均可支配收入累计值(元)      23772      82429      61915      42348      22636   \n",
       "8   农村居民人均可支配收入累计值(元)      12891      38521      31985      22535      12006   \n",
       "9     居民人均可支配收入累计值(元)      19366      57541      44712      30998      18263   \n",
       "10  城镇居民人均可支配收入累计值(元)      22784      68487      52758      36294      21600   \n",
       "11  农村居民人均可支配收入累计值(元)      12541      35247      28474      20357      11686   \n",
       "12    居民人均可支配收入累计值(元)      16490      47498      36227      25119      15500   \n",
       "13  城镇居民人均可支配收入累计值(元)      19251      57743      44267      30491      18194   \n",
       "14  农村居民人均可支配收入累计值(元)      10952      26791      20267      14455      10215   \n",
       "\n",
       "     地区  \n",
       "0   广东省  \n",
       "1   广东省  \n",
       "2   广东省  \n",
       "3    北京  \n",
       "4    北京  \n",
       "5    北京  \n",
       "6   上海市  \n",
       "7   上海市  \n",
       "8   上海市  \n",
       "9   浙江省  \n",
       "10  浙江省  \n",
       "11  浙江省  \n",
       "12  江苏省  \n",
       "13  江苏省  \n",
       "14  江苏省  "
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.read_csv('data/居民人均可支配收入.csv',encoding='utf-8')\n",
    "df = pd.read_csv('data/居民人均可支配收入.csv')\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>指标</th>\n",
       "      <th>2022年第一季度</th>\n",
       "      <th>2021年第四季度</th>\n",
       "      <th>2021年第三季度</th>\n",
       "      <th>2021年第二季度</th>\n",
       "      <th>2021年第一季度</th>\n",
       "      <th>地区</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>居民人均可支配收入累计值(元)</td>\n",
       "      <td>13360</td>\n",
       "      <td>44993</td>\n",
       "      <td>35694</td>\n",
       "      <td>23604</td>\n",
       "      <td>12636</td>\n",
       "      <td>广东省</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>居民人均可支配收入累计值(元)</td>\n",
       "      <td>20630</td>\n",
       "      <td>75002</td>\n",
       "      <td>56498</td>\n",
       "      <td>38138</td>\n",
       "      <td>19585</td>\n",
       "      <td>北京</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>居民人均可支配收入累计值(元)</td>\n",
       "      <td>22663</td>\n",
       "      <td>78027</td>\n",
       "      <td>58907</td>\n",
       "      <td>40357</td>\n",
       "      <td>21548</td>\n",
       "      <td>上海市</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>居民人均可支配收入累计值(元)</td>\n",
       "      <td>19366</td>\n",
       "      <td>57541</td>\n",
       "      <td>44712</td>\n",
       "      <td>30998</td>\n",
       "      <td>18263</td>\n",
       "      <td>浙江省</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>居民人均可支配收入累计值(元)</td>\n",
       "      <td>16490</td>\n",
       "      <td>47498</td>\n",
       "      <td>36227</td>\n",
       "      <td>25119</td>\n",
       "      <td>15500</td>\n",
       "      <td>江苏省</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                 指标  2022年第一季度  2021年第四季度  2021年第三季度  2021年第二季度  2021年第一季度  \\\n",
       "0   居民人均可支配收入累计值(元)      13360      44993      35694      23604      12636   \n",
       "3   居民人均可支配收入累计值(元)      20630      75002      56498      38138      19585   \n",
       "6   居民人均可支配收入累计值(元)      22663      78027      58907      40357      21548   \n",
       "9   居民人均可支配收入累计值(元)      19366      57541      44712      30998      18263   \n",
       "12  居民人均可支配收入累计值(元)      16490      47498      36227      25119      15500   \n",
       "\n",
       "     地区  \n",
       "0   广东省  \n",
       "3    北京  \n",
       "6   上海市  \n",
       "9   浙江省  \n",
       "12  江苏省  "
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "居民人均可支配收入累计值 = df.query('指标==\"居民人均可支配收入累计值(元)\"')\n",
    "居民人均可支配收入累计值"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "5"
      ]
     },
     "execution_count": 28,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(Q5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [],
   "source": [
    "area=居民人均可支配收入累计值['地区'].to_list()\n",
    "Q1=居民人均可支配收入累计值['2022年第一季度'].to_list()\n",
    "Q2=居民人均可支配收入累计值['2021年第四季度'].to_list()\n",
    "Q3=居民人均可支配收入累计值['2021年第三季度'].to_list()\n",
    "Q4=居民人均可支配收入累计值['2021年第二季度'].to_list()\n",
    "Q5=居民人均可支配收入累计值['2021年第一季度'].to_list()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'area': ['广东省', '北京', '上海市', '浙江省', '江苏省'],\n",
       " '2022年第一季度': [13360, 20630, 22663, 19366, 16490],\n",
       " '2021年第四季度': [44993, 75002, 78027, 57541, 47498],\n",
       " '2021年第三季度': [35694, 56498, 58907, 44712, 36227],\n",
       " '2021年第二季度': [23604, 38138, 40357, 30998, 25119],\n",
       " '2021年第一季度': [12636, 19585, 21548, 18263, 15500]}"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data = {'area' : area,\n",
    "        '2022年第一季度': Q1,\n",
    "        '2021年第四季度': Q2,\n",
    "        '2021年第三季度': Q3,\n",
    "        '2021年第二季度':Q4,\n",
    "        '2021年第一季度':Q5,\n",
    "       }\n",
    "colors= Spectral5\n",
    "data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 109,
   "metadata": {},
   "outputs": [],
   "source": [
    "area=居民人均可支配收入累计值['地区'].to_list()\n",
    "Q1=居民人均可支配收入累计值['2022年第一季度'].to_list()\n",
    "Q2=居民人均可支配收入累计值['2021年第四季度'].to_list()\n",
    "Q3=居民人均可支配收入累计值['2021年第三季度'].to_list()\n",
    "Q4=居民人均可支配收入累计值['2021年第二季度'].to_list()\n",
    "Q5=居民人均可支配收入累计值['2021年第一季度'].to_list()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 110,
   "metadata": {},
   "outputs": [],
   "source": [
    "zb=[\"2022年第一季度\", \"2021年第四季度\", \"2021年第三季度\",\"2021年第二季度\",\"2021年第一季度\"]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 111,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "BokehDeprecationWarning: 'legend' keyword is deprecated, use explicit 'legend_label', 'legend_field', or 'legend_group' keywords instead\n",
      "BokehDeprecationWarning: 'legend' keyword is deprecated, use explicit 'legend_label', 'legend_field', or 'legend_group' keywords instead\n",
      "BokehDeprecationWarning: 'legend' keyword is deprecated, use explicit 'legend_label', 'legend_field', or 'legend_group' keywords instead\n",
      "BokehDeprecationWarning: 'legend' keyword is deprecated, use explicit 'legend_label', 'legend_field', or 'legend_group' keywords instead\n",
      "BokehDeprecationWarning: 'legend' keyword is deprecated, use explicit 'legend_label', 'legend_field', or 'legend_group' keywords instead\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "\n",
       "\n",
       "\n",
       "\n",
       "\n",
       "\n",
       "  <div class=\"bk-root\" id=\"52d47bd6-4eaa-4b45-956b-bf739033f4b9\" data-root-id=\"3054\"></div>\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "application/javascript": [
       "(function(root) {\n",
       "  function embed_document(root) {\n",
       "    \n",
       "  var docs_json = {\"4837a8ae-340a-4de5-a273-73daed00808d\":{\"roots\":{\"references\":[{\"attributes\":{\"below\":[{\"id\":\"3065\"}],\"center\":[{\"id\":\"3067\"},{\"id\":\"3071\"},{\"id\":\"3111\"}],\"left\":[{\"id\":\"3068\"}],\"plot_height\":300,\"renderers\":[{\"id\":\"3101\"},{\"id\":\"3116\"},{\"id\":\"3130\"},{\"id\":\"3144\"},{\"id\":\"3158\"}],\"title\":{\"id\":\"3055\"},\"toolbar\":{\"id\":\"3080\"},\"x_range\":{\"id\":\"3057\"},\"x_scale\":{\"id\":\"3061\"},\"y_range\":{\"id\":\"3059\"},\"y_scale\":{\"id\":\"3063\"}},\"id\":\"3054\",\"subtype\":\"Figure\",\"type\":\"Plot\"},{\"attributes\":{\"fields\":[\"2022\\u5e74\\u7b2c\\u4e00\\u5b63\\u5ea6\",\"2021\\u5e74\\u7b2c\\u56db\\u5b63\\u5ea6\",\"2021\\u5e74\\u7b2c\\u4e09\\u5b63\\u5ea6\"]},\"id\":\"3093\",\"type\":\"Stack\"},{\"attributes\":{\"callback\":null,\"tooltips\":[[\"\",\"@area:@$name\"]]},\"id\":\"3079\",\"type\":\"HoverTool\"},{\"attributes\":{\"source\":{\"id\":\"3053\"}},\"id\":\"3159\",\"type\":\"CDSView\"},{\"attributes\":{\"data_source\":{\"id\":\"3053\"},\"glyph\":{\"id\":\"3099\"},\"hover_glyph\":null,\"muted_glyph\":null,\"name\":\"2022\\u5e74\\u7b2c\\u4e00\\u5b63\\u5ea6\",\"nonselection_glyph\":{\"id\":\"3100\"},\"selection_glyph\":null,\"view\":{\"id\":\"3102\"}},\"id\":\"3101\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"data\":{\"2021\\u5e74\\u7b2c\\u4e00\\u5b63\\u5ea6\":[12636,19585,21548,18263,15500],\"2021\\u5e74\\u7b2c\\u4e09\\u5b63\\u5ea6\":[35694,56498,58907,44712,36227],\"2021\\u5e74\\u7b2c\\u4e8c\\u5b63\\u5ea6\":[23604,38138,40357,30998,25119],\"2021\\u5e74\\u7b2c\\u56db\\u5b63\\u5ea6\":[44993,75002,78027,57541,47498],\"2022\\u5e74\\u7b2c\\u4e00\\u5b63\\u5ea6\":[13360,20630,22663,19366,16490],\"area\":[\"\\u5e7f\\u4e1c\\u7701\",\"\\u5317\\u4eac\",\"\\u4e0a\\u6d77\\u5e02\",\"\\u6d59\\u6c5f\\u7701\",\"\\u6c5f\\u82cf\\u7701\"]},\"selected\":{\"id\":\"3110\"},\"selection_policy\":{\"id\":\"3109\"}},\"id\":\"3053\",\"type\":\"ColumnDataSource\"},{\"attributes\":{},\"id\":\"3104\",\"type\":\"CategoricalTickFormatter\"},{\"attributes\":{\"bottom\":{\"expr\":{\"id\":\"3092\"}},\"fill_color\":{\"value\":\"#ffffbf\"},\"line_color\":{\"value\":\"#ffffbf\"},\"top\":{\"expr\":{\"id\":\"3093\"}},\"width\":{\"value\":0.6},\"x\":{\"field\":\"area\"}},\"id\":\"3128\",\"type\":\"VBar\"},{\"attributes\":{\"text\":\"\\u5c45\\u6c11\\u4eba\\u5747\\u53ef\\u652f\\u914d\\u6536\\u5165\\u7d2f\\u8ba1\\u503c\"},\"id\":\"3055\",\"type\":\"Title\"},{\"attributes\":{\"bottom\":{\"expr\":{\"id\":\"3096\"}},\"fill_alpha\":{\"value\":0.1},\"fill_color\":{\"value\":\"#d7191c\"},\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"#d7191c\"},\"top\":{\"expr\":{\"id\":\"3097\"}},\"width\":{\"value\":0.6},\"x\":{\"field\":\"area\"}},\"id\":\"3157\",\"type\":\"VBar\"},{\"attributes\":{\"fields\":[]},\"id\":\"3088\",\"type\":\"Stack\"},{\"attributes\":{\"factors\":[\"\\u5e7f\\u4e1c\\u7701\",\"\\u5317\\u4eac\",\"\\u4e0a\\u6d77\\u5e02\",\"\\u6d59\\u6c5f\\u7701\",\"\\u6c5f\\u82cf\\u7701\"],\"range_padding\":0.1},\"id\":\"3057\",\"type\":\"FactorRange\"},{\"attributes\":{\"bottom\":{\"expr\":{\"id\":\"3088\"}},\"fill_alpha\":{\"value\":0.1},\"fill_color\":{\"value\":\"#2b83ba\"},\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"#2b83ba\"},\"top\":{\"expr\":{\"id\":\"3089\"}},\"width\":{\"value\":0.6},\"x\":{\"field\":\"area\"}},\"id\":\"3100\",\"type\":\"VBar\"},{\"attributes\":{},\"id\":\"3106\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{},\"id\":\"3077\",\"type\":\"HelpTool\"},{\"attributes\":{\"bottom\":{\"expr\":{\"id\":\"3092\"}},\"fill_alpha\":{\"value\":0.1},\"fill_color\":{\"value\":\"#ffffbf\"},\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"#ffffbf\"},\"top\":{\"expr\":{\"id\":\"3093\"}},\"width\":{\"value\":0.6},\"x\":{\"field\":\"area\"}},\"id\":\"3129\",\"type\":\"VBar\"},{\"attributes\":{\"data_source\":{\"id\":\"3053\"},\"glyph\":{\"id\":\"3156\"},\"hover_glyph\":null,\"muted_glyph\":null,\"name\":\"2021\\u5e74\\u7b2c\\u4e00\\u5b63\\u5ea6\",\"nonselection_glyph\":{\"id\":\"3157\"},\"selection_glyph\":null,\"view\":{\"id\":\"3159\"}},\"id\":\"3158\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"fields\":[\"2022\\u5e74\\u7b2c\\u4e00\\u5b63\\u5ea6\",\"2021\\u5e74\\u7b2c\\u56db\\u5b63\\u5ea6\",\"2021\\u5e74\\u7b2c\\u4e09\\u5b63\\u5ea6\",\"2021\\u5e74\\u7b2c\\u4e8c\\u5b63\\u5ea6\",\"2021\\u5e74\\u7b2c\\u4e00\\u5b63\\u5ea6\"]},\"id\":\"3097\",\"type\":\"Stack\"},{\"attributes\":{\"fields\":[\"2022\\u5e74\\u7b2c\\u4e00\\u5b63\\u5ea6\"]},\"id\":\"3089\",\"type\":\"Stack\"},{\"attributes\":{\"source\":{\"id\":\"3053\"}},\"id\":\"3102\",\"type\":\"CDSView\"},{\"attributes\":{\"fields\":[\"2022\\u5e74\\u7b2c\\u4e00\\u5b63\\u5ea6\",\"2021\\u5e74\\u7b2c\\u56db\\u5b63\\u5ea6\"]},\"id\":\"3091\",\"type\":\"Stack\"},{\"attributes\":{\"bottom\":{\"expr\":{\"id\":\"3090\"}},\"fill_alpha\":{\"value\":0.1},\"fill_color\":{\"value\":\"#abdda4\"},\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"#abdda4\"},\"top\":{\"expr\":{\"id\":\"3091\"}},\"width\":{\"value\":0.6},\"x\":{\"field\":\"area\"}},\"id\":\"3115\",\"type\":\"VBar\"},{\"attributes\":{},\"id\":\"3061\",\"type\":\"CategoricalScale\"},{\"attributes\":{\"source\":{\"id\":\"3053\"}},\"id\":\"3117\",\"type\":\"CDSView\"},{\"attributes\":{\"bottom\":{\"expr\":{\"id\":\"3094\"}},\"fill_color\":{\"value\":\"#fdae61\"},\"line_color\":{\"value\":\"#fdae61\"},\"top\":{\"expr\":{\"id\":\"3095\"}},\"width\":{\"value\":0.6},\"x\":{\"field\":\"area\"}},\"id\":\"3142\",\"type\":\"VBar\"},{\"attributes\":{},\"id\":\"3069\",\"type\":\"BasicTicker\"},{\"attributes\":{\"fields\":[\"2022\\u5e74\\u7b2c\\u4e00\\u5b63\\u5ea6\",\"2021\\u5e74\\u7b2c\\u56db\\u5b63\\u5ea6\",\"2021\\u5e74\\u7b2c\\u4e09\\u5b63\\u5ea6\"]},\"id\":\"3094\",\"type\":\"Stack\"},{\"attributes\":{\"start\":0},\"id\":\"3059\",\"type\":\"DataRange1d\"},{\"attributes\":{\"bottom\":{\"expr\":{\"id\":\"3094\"}},\"fill_alpha\":{\"value\":0.1},\"fill_color\":{\"value\":\"#fdae61\"},\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"#fdae61\"},\"top\":{\"expr\":{\"id\":\"3095\"}},\"width\":{\"value\":0.6},\"x\":{\"field\":\"area\"}},\"id\":\"3143\",\"type\":\"VBar\"},{\"attributes\":{\"formatter\":{\"id\":\"3104\"},\"ticker\":{\"id\":\"3066\"}},\"id\":\"3065\",\"type\":\"CategoricalAxis\"},{\"attributes\":{\"data_source\":{\"id\":\"3053\"},\"glyph\":{\"id\":\"3114\"},\"hover_glyph\":null,\"muted_glyph\":null,\"name\":\"2021\\u5e74\\u7b2c\\u56db\\u5b63\\u5ea6\",\"nonselection_glyph\":{\"id\":\"3115\"},\"selection_glyph\":null,\"view\":{\"id\":\"3117\"}},\"id\":\"3116\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"active_drag\":\"auto\",\"active_inspect\":\"auto\",\"active_multi\":null,\"active_scroll\":\"auto\",\"active_tap\":\"auto\",\"tools\":[{\"id\":\"3072\"},{\"id\":\"3073\"},{\"id\":\"3074\"},{\"id\":\"3075\"},{\"id\":\"3076\"},{\"id\":\"3077\"},{\"id\":\"3079\"}]},\"id\":\"3080\",\"type\":\"Toolbar\"},{\"attributes\":{\"axis\":{\"id\":\"3068\"},\"dimension\":1,\"ticker\":null},\"id\":\"3071\",\"type\":\"Grid\"},{\"attributes\":{},\"id\":\"3066\",\"type\":\"CategoricalTicker\"},{\"attributes\":{\"label\":{\"value\":\"2021\\u5e74\\u7b2c\\u4e00\\u5b63\\u5ea6\"},\"renderers\":[{\"id\":\"3158\"}]},\"id\":\"3168\",\"type\":\"LegendItem\"},{\"attributes\":{\"bottom_units\":\"screen\",\"fill_alpha\":0.5,\"fill_color\":\"lightgrey\",\"left_units\":\"screen\",\"level\":\"overlay\",\"line_alpha\":1.0,\"line_color\":\"black\",\"line_dash\":[4,4],\"line_width\":2,\"right_units\":\"screen\",\"top_units\":\"screen\"},\"id\":\"3078\",\"type\":\"BoxAnnotation\"},{\"attributes\":{\"fields\":[\"2022\\u5e74\\u7b2c\\u4e00\\u5b63\\u5ea6\"]},\"id\":\"3090\",\"type\":\"Stack\"},{\"attributes\":{\"label\":{\"value\":\"2021\\u5e74\\u7b2c\\u4e09\\u5b63\\u5ea6\"},\"renderers\":[{\"id\":\"3130\"}]},\"id\":\"3140\",\"type\":\"LegendItem\"},{\"attributes\":{\"fields\":[\"2022\\u5e74\\u7b2c\\u4e00\\u5b63\\u5ea6\",\"2021\\u5e74\\u7b2c\\u56db\\u5b63\\u5ea6\",\"2021\\u5e74\\u7b2c\\u4e09\\u5b63\\u5ea6\",\"2021\\u5e74\\u7b2c\\u4e8c\\u5b63\\u5ea6\"]},\"id\":\"3096\",\"type\":\"Stack\"},{\"attributes\":{\"label\":{\"value\":\"2022\\u5e74\\u7b2c\\u4e00\\u5b63\\u5ea6\"},\"renderers\":[{\"id\":\"3101\"}]},\"id\":\"3112\",\"type\":\"LegendItem\"},{\"attributes\":{\"bottom\":{\"expr\":{\"id\":\"3088\"}},\"fill_color\":{\"value\":\"#2b83ba\"},\"line_color\":{\"value\":\"#2b83ba\"},\"top\":{\"expr\":{\"id\":\"3089\"}},\"width\":{\"value\":0.6},\"x\":{\"field\":\"area\"}},\"id\":\"3099\",\"type\":\"VBar\"},{\"attributes\":{\"bottom\":{\"expr\":{\"id\":\"3096\"}},\"fill_color\":{\"value\":\"#d7191c\"},\"line_color\":{\"value\":\"#d7191c\"},\"top\":{\"expr\":{\"id\":\"3097\"}},\"width\":{\"value\":0.6},\"x\":{\"field\":\"area\"}},\"id\":\"3156\",\"type\":\"VBar\"},{\"attributes\":{\"label\":{\"value\":\"2021\\u5e74\\u7b2c\\u56db\\u5b63\\u5ea6\"},\"renderers\":[{\"id\":\"3116\"}]},\"id\":\"3126\",\"type\":\"LegendItem\"},{\"attributes\":{\"axis\":{\"id\":\"3065\"},\"ticker\":null},\"id\":\"3067\",\"type\":\"Grid\"},{\"attributes\":{\"bottom\":{\"expr\":{\"id\":\"3090\"}},\"fill_color\":{\"value\":\"#abdda4\"},\"line_color\":{\"value\":\"#abdda4\"},\"top\":{\"expr\":{\"id\":\"3091\"}},\"width\":{\"value\":0.6},\"x\":{\"field\":\"area\"}},\"id\":\"3114\",\"type\":\"VBar\"},{\"attributes\":{\"source\":{\"id\":\"3053\"}},\"id\":\"3131\",\"type\":\"CDSView\"},{\"attributes\":{\"formatter\":{\"id\":\"3106\"},\"ticker\":{\"id\":\"3069\"}},\"id\":\"3068\",\"type\":\"LinearAxis\"},{\"attributes\":{\"fields\":[\"2022\\u5e74\\u7b2c\\u4e00\\u5b63\\u5ea6\",\"2021\\u5e74\\u7b2c\\u56db\\u5b63\\u5ea6\",\"2021\\u5e74\\u7b2c\\u4e09\\u5b63\\u5ea6\",\"2021\\u5e74\\u7b2c\\u4e8c\\u5b63\\u5ea6\"]},\"id\":\"3095\",\"type\":\"Stack\"},{\"attributes\":{},\"id\":\"3076\",\"type\":\"ResetTool\"},{\"attributes\":{\"overlay\":{\"id\":\"3078\"}},\"id\":\"3074\",\"type\":\"BoxZoomTool\"},{\"attributes\":{\"source\":{\"id\":\"3053\"}},\"id\":\"3145\",\"type\":\"CDSView\"},{\"attributes\":{},\"id\":\"3075\",\"type\":\"SaveTool\"},{\"attributes\":{},\"id\":\"3110\",\"type\":\"Selection\"},{\"attributes\":{},\"id\":\"3063\",\"type\":\"LinearScale\"},{\"attributes\":{},\"id\":\"3072\",\"type\":\"PanTool\"},{\"attributes\":{\"fields\":[\"2022\\u5e74\\u7b2c\\u4e00\\u5b63\\u5ea6\",\"2021\\u5e74\\u7b2c\\u56db\\u5b63\\u5ea6\"]},\"id\":\"3092\",\"type\":\"Stack\"},{\"attributes\":{},\"id\":\"3073\",\"type\":\"WheelZoomTool\"},{\"attributes\":{\"data_source\":{\"id\":\"3053\"},\"glyph\":{\"id\":\"3128\"},\"hover_glyph\":null,\"muted_glyph\":null,\"name\":\"2021\\u5e74\\u7b2c\\u4e09\\u5b63\\u5ea6\",\"nonselection_glyph\":{\"id\":\"3129\"},\"selection_glyph\":null,\"view\":{\"id\":\"3131\"}},\"id\":\"3130\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"data_source\":{\"id\":\"3053\"},\"glyph\":{\"id\":\"3142\"},\"hover_glyph\":null,\"muted_glyph\":null,\"name\":\"2021\\u5e74\\u7b2c\\u4e8c\\u5b63\\u5ea6\",\"nonselection_glyph\":{\"id\":\"3143\"},\"selection_glyph\":null,\"view\":{\"id\":\"3145\"}},\"id\":\"3144\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"label\":{\"value\":\"2021\\u5e74\\u7b2c\\u4e8c\\u5b63\\u5ea6\"},\"renderers\":[{\"id\":\"3144\"}]},\"id\":\"3154\",\"type\":\"LegendItem\"},{\"attributes\":{\"items\":[{\"id\":\"3112\"},{\"id\":\"3126\"},{\"id\":\"3140\"},{\"id\":\"3154\"},{\"id\":\"3168\"}]},\"id\":\"3111\",\"type\":\"Legend\"},{\"attributes\":{},\"id\":\"3109\",\"type\":\"UnionRenderers\"}],\"root_ids\":[\"3054\"]},\"title\":\"Bokeh Application\",\"version\":\"2.1.1\"}};\n",
       "  var render_items = [{\"docid\":\"4837a8ae-340a-4de5-a273-73daed00808d\",\"root_ids\":[\"3054\"],\"roots\":{\"3054\":\"52d47bd6-4eaa-4b45-956b-bf739033f4b9\"}}];\n",
       "  root.Bokeh.embed.embed_items_notebook(docs_json, render_items);\n",
       "\n",
       "  }\n",
       "  if (root.Bokeh !== undefined) {\n",
       "    embed_document(root);\n",
       "  } else {\n",
       "    var attempts = 0;\n",
       "    var timer = setInterval(function(root) {\n",
       "      if (root.Bokeh !== undefined) {\n",
       "        clearInterval(timer);\n",
       "        embed_document(root);\n",
       "      } else {\n",
       "        attempts++;\n",
       "        if (attempts > 100) {\n",
       "          clearInterval(timer);\n",
       "          console.log(\"Bokeh: ERROR: Unable to run BokehJS code because BokehJS library is missing\");\n",
       "        }\n",
       "      }\n",
       "    }, 10, root)\n",
       "  }\n",
       "})(window);"
      ],
      "application/vnd.bokehjs_exec.v0+json": ""
     },
     "metadata": {
      "application/vnd.bokehjs_exec.v0+json": {
       "id": "3054"
      }
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "source= ColumnDataSource(\n",
    "    data=data\n",
    ")\n",
    "\n",
    "# 点击的交互式数据\n",
    "tooltip =[\n",
    "#     ('标题','数据')\n",
    "    (\"\",'@area:@$name')\n",
    "    \n",
    "]\n",
    "# 画布\n",
    "p = figure(\n",
    "    x_range=area, \n",
    "       plot_height=300, \n",
    "       title=\"居民人均可支配收入累计值\",\n",
    "       tooltips=tooltip\n",
    ")\n",
    "p.vbar_stack(zb, x='area', width=0.6, color=colors, source=source,\n",
    "             legend=[value(x) for x in zb]) \n",
    "\n",
    "# 其他\n",
    "p.y_range.start = 0\n",
    "p.x_range.range_padding = 0.1\n",
    "\n",
    "show(p)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [],
   "source": [
    "area = ['广东省', '北京市', '上海市', '浙江省', '江苏省' ]\n",
    "time = [\"2022年第一季度\",\"2021年第四季度\",\"2021年第三季度\",\"2021年第二季度\",\"2021年第一季度\"]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'area': ['广东省', '北京市', '上海市', '浙江省', '江苏省'],\n",
       " '2022年第一季度': [13360, 20630, 22663, 19366, 16490],\n",
       " '2021年第四季度': [44993, 75002, 78027, 57541, 47498],\n",
       " '2021年第三季度': [35694, 56498, 58907, 44712, 36227],\n",
       " '2021年第二季度': [23604, 38138, 40357, 30998, 25119],\n",
       " '2021年第一季度': [12636, 19585, 21548, 18263, 15500]}"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 堆叠数据\n",
    "data = {'area' : ['广东省', '北京市', '上海市', '浙江省', '江苏省'],\n",
    "        '2022年第一季度' : [13360, 20630, 22663, 19366, 16490],\n",
    "        '2021年第四季度': [44993, 75002, 78027, 57541, 47498],\n",
    "        '2021年第三季度' : [35694, 56498, 58907, 44712, 36227],\n",
    "        '2021年第二季度': [23604, 38138, 40357, 30998, 25119],\n",
    "        '2021年第一季度' : [12636, 19585, 21548, 18263,15500]}\n",
    "# 颜色的准备\n",
    "colors = Spectral5\n",
    "\n",
    "data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "BokehDeprecationWarning: 'legend' keyword is deprecated, use explicit 'legend_label', 'legend_field', or 'legend_group' keywords instead\n",
      "BokehDeprecationWarning: 'legend' keyword is deprecated, use explicit 'legend_label', 'legend_field', or 'legend_group' keywords instead\n",
      "BokehDeprecationWarning: 'legend' keyword is deprecated, use explicit 'legend_label', 'legend_field', or 'legend_group' keywords instead\n",
      "BokehDeprecationWarning: 'legend' keyword is deprecated, use explicit 'legend_label', 'legend_field', or 'legend_group' keywords instead\n",
      "BokehDeprecationWarning: 'legend' keyword is deprecated, use explicit 'legend_label', 'legend_field', or 'legend_group' keywords instead\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "\n",
       "\n",
       "\n",
       "\n",
       "\n",
       "\n",
       "  <div class=\"bk-root\" id=\"5b920874-26a5-4ac3-81c1-83212af9a0b5\" data-root-id=\"1345\"></div>\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "application/javascript": [
       "(function(root) {\n",
       "  function embed_document(root) {\n",
       "    \n",
       "  var docs_json = {\"f636f8b0-d10f-46a9-b9da-9a922656568c\":{\"roots\":{\"references\":[{\"attributes\":{\"below\":[{\"id\":\"1356\"}],\"center\":[{\"id\":\"1358\"},{\"id\":\"1362\"},{\"id\":\"1402\"}],\"left\":[{\"id\":\"1359\"}],\"plot_height\":300,\"renderers\":[{\"id\":\"1392\"},{\"id\":\"1407\"},{\"id\":\"1421\"},{\"id\":\"1435\"},{\"id\":\"1449\"}],\"title\":{\"id\":\"1346\"},\"toolbar\":{\"id\":\"1371\"},\"x_range\":{\"id\":\"1348\"},\"x_scale\":{\"id\":\"1352\"},\"y_range\":{\"id\":\"1350\"},\"y_scale\":{\"id\":\"1354\"}},\"id\":\"1345\",\"subtype\":\"Figure\",\"type\":\"Plot\"},{\"attributes\":{\"bottom\":{\"expr\":{\"id\":\"1381\"}},\"fill_color\":{\"value\":\"#abdda4\"},\"line_color\":{\"value\":\"#abdda4\"},\"top\":{\"expr\":{\"id\":\"1382\"}},\"width\":{\"value\":0.6},\"x\":{\"field\":\"area\"}},\"id\":\"1405\",\"type\":\"VBar\"},{\"attributes\":{},\"id\":\"1397\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{\"text\":\"\\u5c45\\u6c11\\u4eba\\u5747\\u53ef\\u652f\\u914d\\u6536\\u5165\\u7d2f\\u8ba1\\u503c\"},\"id\":\"1346\",\"type\":\"Title\"},{\"attributes\":{\"fields\":[\"2022\\u5e74\\u7b2c\\u4e00\\u5b63\\u5ea6\",\"2021\\u5e74\\u7b2c\\u56db\\u5b63\\u5ea6\",\"2021\\u5e74\\u7b2c\\u4e09\\u5b63\\u5ea6\",\"2021\\u5e74\\u7b2c\\u4e8c\\u5b63\\u5ea6\",\"2021\\u5e74\\u7b2c\\u4e00\\u5b63\\u5ea6\"]},\"id\":\"1388\",\"type\":\"Stack\"},{\"attributes\":{\"source\":{\"id\":\"1344\"}},\"id\":\"1408\",\"type\":\"CDSView\"},{\"attributes\":{\"formatter\":{\"id\":\"1395\"},\"ticker\":{\"id\":\"1357\"}},\"id\":\"1356\",\"type\":\"CategoricalAxis\"},{\"attributes\":{},\"id\":\"1352\",\"type\":\"CategoricalScale\"},{\"attributes\":{\"bottom\":{\"expr\":{\"id\":\"1379\"}},\"fill_color\":{\"value\":\"#2b83ba\"},\"line_color\":{\"value\":\"#2b83ba\"},\"top\":{\"expr\":{\"id\":\"1380\"}},\"width\":{\"value\":0.6},\"x\":{\"field\":\"area\"}},\"id\":\"1390\",\"type\":\"VBar\"},{\"attributes\":{\"data_source\":{\"id\":\"1344\"},\"glyph\":{\"id\":\"1390\"},\"hover_glyph\":null,\"muted_glyph\":null,\"name\":\"2022\\u5e74\\u7b2c\\u4e00\\u5b63\\u5ea6\",\"nonselection_glyph\":{\"id\":\"1391\"},\"selection_glyph\":null,\"view\":{\"id\":\"1393\"}},\"id\":\"1392\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"callback\":null,\"tooltips\":[[\"\",\"@area:@$name\"]]},\"id\":\"1370\",\"type\":\"HoverTool\"},{\"attributes\":{\"bottom\":{\"expr\":{\"id\":\"1383\"}},\"fill_alpha\":{\"value\":0.1},\"fill_color\":{\"value\":\"#ffffbf\"},\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"#ffffbf\"},\"top\":{\"expr\":{\"id\":\"1384\"}},\"width\":{\"value\":0.6},\"x\":{\"field\":\"area\"}},\"id\":\"1420\",\"type\":\"VBar\"},{\"attributes\":{\"bottom\":{\"expr\":{\"id\":\"1387\"}},\"fill_color\":{\"value\":\"#d7191c\"},\"line_color\":{\"value\":\"#d7191c\"},\"top\":{\"expr\":{\"id\":\"1388\"}},\"width\":{\"value\":0.6},\"x\":{\"field\":\"area\"}},\"id\":\"1447\",\"type\":\"VBar\"},{\"attributes\":{},\"id\":\"1401\",\"type\":\"Selection\"},{\"attributes\":{\"fields\":[\"2022\\u5e74\\u7b2c\\u4e00\\u5b63\\u5ea6\",\"2021\\u5e74\\u7b2c\\u56db\\u5b63\\u5ea6\",\"2021\\u5e74\\u7b2c\\u4e09\\u5b63\\u5ea6\"]},\"id\":\"1384\",\"type\":\"Stack\"},{\"attributes\":{\"fields\":[\"2022\\u5e74\\u7b2c\\u4e00\\u5b63\\u5ea6\",\"2021\\u5e74\\u7b2c\\u56db\\u5b63\\u5ea6\",\"2021\\u5e74\\u7b2c\\u4e09\\u5b63\\u5ea6\",\"2021\\u5e74\\u7b2c\\u4e8c\\u5b63\\u5ea6\"]},\"id\":\"1386\",\"type\":\"Stack\"},{\"attributes\":{\"start\":0},\"id\":\"1350\",\"type\":\"DataRange1d\"},{\"attributes\":{\"active_drag\":\"auto\",\"active_inspect\":\"auto\",\"active_multi\":null,\"active_scroll\":\"auto\",\"active_tap\":\"auto\",\"tools\":[{\"id\":\"1363\"},{\"id\":\"1364\"},{\"id\":\"1365\"},{\"id\":\"1366\"},{\"id\":\"1367\"},{\"id\":\"1368\"},{\"id\":\"1370\"}]},\"id\":\"1371\",\"type\":\"Toolbar\"},{\"attributes\":{\"axis\":{\"id\":\"1356\"},\"ticker\":null},\"id\":\"1358\",\"type\":\"Grid\"},{\"attributes\":{\"data_source\":{\"id\":\"1344\"},\"glyph\":{\"id\":\"1405\"},\"hover_glyph\":null,\"muted_glyph\":null,\"name\":\"2021\\u5e74\\u7b2c\\u56db\\u5b63\\u5ea6\",\"nonselection_glyph\":{\"id\":\"1406\"},\"selection_glyph\":null,\"view\":{\"id\":\"1408\"}},\"id\":\"1407\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"data_source\":{\"id\":\"1344\"},\"glyph\":{\"id\":\"1433\"},\"hover_glyph\":null,\"muted_glyph\":null,\"name\":\"2021\\u5e74\\u7b2c\\u4e8c\\u5b63\\u5ea6\",\"nonselection_glyph\":{\"id\":\"1434\"},\"selection_glyph\":null,\"view\":{\"id\":\"1436\"}},\"id\":\"1435\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"source\":{\"id\":\"1344\"}},\"id\":\"1422\",\"type\":\"CDSView\"},{\"attributes\":{\"label\":{\"value\":\"2021\\u5e74\\u7b2c\\u56db\\u5b63\\u5ea6\"},\"renderers\":[{\"id\":\"1407\"}]},\"id\":\"1417\",\"type\":\"LegendItem\"},{\"attributes\":{\"bottom\":{\"expr\":{\"id\":\"1379\"}},\"fill_alpha\":{\"value\":0.1},\"fill_color\":{\"value\":\"#2b83ba\"},\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"#2b83ba\"},\"top\":{\"expr\":{\"id\":\"1380\"}},\"width\":{\"value\":0.6},\"x\":{\"field\":\"area\"}},\"id\":\"1391\",\"type\":\"VBar\"},{\"attributes\":{},\"id\":\"1364\",\"type\":\"WheelZoomTool\"},{\"attributes\":{\"label\":{\"value\":\"2021\\u5e74\\u7b2c\\u4e00\\u5b63\\u5ea6\"},\"renderers\":[{\"id\":\"1449\"}]},\"id\":\"1459\",\"type\":\"LegendItem\"},{\"attributes\":{\"fields\":[\"2022\\u5e74\\u7b2c\\u4e00\\u5b63\\u5ea6\",\"2021\\u5e74\\u7b2c\\u56db\\u5b63\\u5ea6\",\"2021\\u5e74\\u7b2c\\u4e09\\u5b63\\u5ea6\",\"2021\\u5e74\\u7b2c\\u4e8c\\u5b63\\u5ea6\"]},\"id\":\"1387\",\"type\":\"Stack\"},{\"attributes\":{},\"id\":\"1368\",\"type\":\"HelpTool\"},{\"attributes\":{\"data_source\":{\"id\":\"1344\"},\"glyph\":{\"id\":\"1419\"},\"hover_glyph\":null,\"muted_glyph\":null,\"name\":\"2021\\u5e74\\u7b2c\\u4e09\\u5b63\\u5ea6\",\"nonselection_glyph\":{\"id\":\"1420\"},\"selection_glyph\":null,\"view\":{\"id\":\"1422\"}},\"id\":\"1421\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"label\":{\"value\":\"2021\\u5e74\\u7b2c\\u4e8c\\u5b63\\u5ea6\"},\"renderers\":[{\"id\":\"1435\"}]},\"id\":\"1445\",\"type\":\"LegendItem\"},{\"attributes\":{\"label\":{\"value\":\"2022\\u5e74\\u7b2c\\u4e00\\u5b63\\u5ea6\"},\"renderers\":[{\"id\":\"1392\"}]},\"id\":\"1403\",\"type\":\"LegendItem\"},{\"attributes\":{},\"id\":\"1367\",\"type\":\"ResetTool\"},{\"attributes\":{},\"id\":\"1357\",\"type\":\"CategoricalTicker\"},{\"attributes\":{},\"id\":\"1400\",\"type\":\"UnionRenderers\"},{\"attributes\":{\"factors\":[\"\\u5e7f\\u4e1c\\u7701\",\"\\u5317\\u4eac\\u5e02\",\"\\u4e0a\\u6d77\\u5e02\",\"\\u6d59\\u6c5f\\u7701\",\"\\u6c5f\\u82cf\\u7701\"],\"range_padding\":0.1},\"id\":\"1348\",\"type\":\"FactorRange\"},{\"attributes\":{\"source\":{\"id\":\"1344\"}},\"id\":\"1393\",\"type\":\"CDSView\"},{\"attributes\":{\"source\":{\"id\":\"1344\"}},\"id\":\"1450\",\"type\":\"CDSView\"},{\"attributes\":{\"label\":{\"value\":\"2021\\u5e74\\u7b2c\\u4e09\\u5b63\\u5ea6\"},\"renderers\":[{\"id\":\"1421\"}]},\"id\":\"1431\",\"type\":\"LegendItem\"},{\"attributes\":{},\"id\":\"1395\",\"type\":\"CategoricalTickFormatter\"},{\"attributes\":{\"bottom\":{\"expr\":{\"id\":\"1385\"}},\"fill_alpha\":{\"value\":0.1},\"fill_color\":{\"value\":\"#fdae61\"},\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"#fdae61\"},\"top\":{\"expr\":{\"id\":\"1386\"}},\"width\":{\"value\":0.6},\"x\":{\"field\":\"area\"}},\"id\":\"1434\",\"type\":\"VBar\"},{\"attributes\":{\"fields\":[]},\"id\":\"1379\",\"type\":\"Stack\"},{\"attributes\":{},\"id\":\"1366\",\"type\":\"SaveTool\"},{\"attributes\":{\"data\":{\"2021\\u5e74\\u7b2c\\u4e00\\u5b63\\u5ea6\":[12636,19585,21548,18263,15500],\"2021\\u5e74\\u7b2c\\u4e09\\u5b63\\u5ea6\":[35694,56498,58907,44712,36227],\"2021\\u5e74\\u7b2c\\u4e8c\\u5b63\\u5ea6\":[23604,38138,40357,30998,25119],\"2021\\u5e74\\u7b2c\\u56db\\u5b63\\u5ea6\":[44993,75002,78027,57541,47498],\"2022\\u5e74\\u7b2c\\u4e00\\u5b63\\u5ea6\":[13360,20630,22663,19366,16490],\"area\":[\"\\u5e7f\\u4e1c\\u7701\",\"\\u5317\\u4eac\\u5e02\",\"\\u4e0a\\u6d77\\u5e02\",\"\\u6d59\\u6c5f\\u7701\",\"\\u6c5f\\u82cf\\u7701\"]},\"selected\":{\"id\":\"1401\"},\"selection_policy\":{\"id\":\"1400\"}},\"id\":\"1344\",\"type\":\"ColumnDataSource\"},{\"attributes\":{\"fields\":[\"2022\\u5e74\\u7b2c\\u4e00\\u5b63\\u5ea6\",\"2021\\u5e74\\u7b2c\\u56db\\u5b63\\u5ea6\"]},\"id\":\"1383\",\"type\":\"Stack\"},{\"attributes\":{\"formatter\":{\"id\":\"1397\"},\"ticker\":{\"id\":\"1360\"}},\"id\":\"1359\",\"type\":\"LinearAxis\"},{\"attributes\":{\"axis\":{\"id\":\"1359\"},\"dimension\":1,\"ticker\":null},\"id\":\"1362\",\"type\":\"Grid\"},{\"attributes\":{\"bottom\":{\"expr\":{\"id\":\"1387\"}},\"fill_alpha\":{\"value\":0.1},\"fill_color\":{\"value\":\"#d7191c\"},\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"#d7191c\"},\"top\":{\"expr\":{\"id\":\"1388\"}},\"width\":{\"value\":0.6},\"x\":{\"field\":\"area\"}},\"id\":\"1448\",\"type\":\"VBar\"},{\"attributes\":{},\"id\":\"1354\",\"type\":\"LinearScale\"},{\"attributes\":{\"bottom\":{\"expr\":{\"id\":\"1385\"}},\"fill_color\":{\"value\":\"#fdae61\"},\"line_color\":{\"value\":\"#fdae61\"},\"top\":{\"expr\":{\"id\":\"1386\"}},\"width\":{\"value\":0.6},\"x\":{\"field\":\"area\"}},\"id\":\"1433\",\"type\":\"VBar\"},{\"attributes\":{\"fields\":[\"2022\\u5e74\\u7b2c\\u4e00\\u5b63\\u5ea6\"]},\"id\":\"1381\",\"type\":\"Stack\"},{\"attributes\":{\"source\":{\"id\":\"1344\"}},\"id\":\"1436\",\"type\":\"CDSView\"},{\"attributes\":{},\"id\":\"1360\",\"type\":\"BasicTicker\"},{\"attributes\":{\"data_source\":{\"id\":\"1344\"},\"glyph\":{\"id\":\"1447\"},\"hover_glyph\":null,\"muted_glyph\":null,\"name\":\"2021\\u5e74\\u7b2c\\u4e00\\u5b63\\u5ea6\",\"nonselection_glyph\":{\"id\":\"1448\"},\"selection_glyph\":null,\"view\":{\"id\":\"1450\"}},\"id\":\"1449\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"fields\":[\"2022\\u5e74\\u7b2c\\u4e00\\u5b63\\u5ea6\",\"2021\\u5e74\\u7b2c\\u56db\\u5b63\\u5ea6\",\"2021\\u5e74\\u7b2c\\u4e09\\u5b63\\u5ea6\"]},\"id\":\"1385\",\"type\":\"Stack\"},{\"attributes\":{\"bottom\":{\"expr\":{\"id\":\"1381\"}},\"fill_alpha\":{\"value\":0.1},\"fill_color\":{\"value\":\"#abdda4\"},\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"#abdda4\"},\"top\":{\"expr\":{\"id\":\"1382\"}},\"width\":{\"value\":0.6},\"x\":{\"field\":\"area\"}},\"id\":\"1406\",\"type\":\"VBar\"},{\"attributes\":{\"bottom_units\":\"screen\",\"fill_alpha\":0.5,\"fill_color\":\"lightgrey\",\"left_units\":\"screen\",\"level\":\"overlay\",\"line_alpha\":1.0,\"line_color\":\"black\",\"line_dash\":[4,4],\"line_width\":2,\"right_units\":\"screen\",\"top_units\":\"screen\"},\"id\":\"1369\",\"type\":\"BoxAnnotation\"},{\"attributes\":{\"fields\":[\"2022\\u5e74\\u7b2c\\u4e00\\u5b63\\u5ea6\"]},\"id\":\"1380\",\"type\":\"Stack\"},{\"attributes\":{\"fields\":[\"2022\\u5e74\\u7b2c\\u4e00\\u5b63\\u5ea6\",\"2021\\u5e74\\u7b2c\\u56db\\u5b63\\u5ea6\"]},\"id\":\"1382\",\"type\":\"Stack\"},{\"attributes\":{},\"id\":\"1363\",\"type\":\"PanTool\"},{\"attributes\":{\"bottom\":{\"expr\":{\"id\":\"1383\"}},\"fill_color\":{\"value\":\"#ffffbf\"},\"line_color\":{\"value\":\"#ffffbf\"},\"top\":{\"expr\":{\"id\":\"1384\"}},\"width\":{\"value\":0.6},\"x\":{\"field\":\"area\"}},\"id\":\"1419\",\"type\":\"VBar\"},{\"attributes\":{\"overlay\":{\"id\":\"1369\"}},\"id\":\"1365\",\"type\":\"BoxZoomTool\"},{\"attributes\":{\"items\":[{\"id\":\"1403\"},{\"id\":\"1417\"},{\"id\":\"1431\"},{\"id\":\"1445\"},{\"id\":\"1459\"}]},\"id\":\"1402\",\"type\":\"Legend\"}],\"root_ids\":[\"1345\"]},\"title\":\"Bokeh Application\",\"version\":\"2.1.1\"}};\n",
       "  var render_items = [{\"docid\":\"f636f8b0-d10f-46a9-b9da-9a922656568c\",\"root_ids\":[\"1345\"],\"roots\":{\"1345\":\"5b920874-26a5-4ac3-81c1-83212af9a0b5\"}}];\n",
       "  root.Bokeh.embed.embed_items_notebook(docs_json, render_items);\n",
       "\n",
       "  }\n",
       "  if (root.Bokeh !== undefined) {\n",
       "    embed_document(root);\n",
       "  } else {\n",
       "    var attempts = 0;\n",
       "    var timer = setInterval(function(root) {\n",
       "      if (root.Bokeh !== undefined) {\n",
       "        clearInterval(timer);\n",
       "        embed_document(root);\n",
       "      } else {\n",
       "        attempts++;\n",
       "        if (attempts > 100) {\n",
       "          clearInterval(timer);\n",
       "          console.log(\"Bokeh: ERROR: Unable to run BokehJS code because BokehJS library is missing\");\n",
       "        }\n",
       "      }\n",
       "    }, 10, root)\n",
       "  }\n",
       "})(window);"
      ],
      "application/vnd.bokehjs_exec.v0+json": ""
     },
     "metadata": {
      "application/vnd.bokehjs_exec.v0+json": {
       "id": "1345"
      }
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "source= ColumnDataSource(\n",
    "    data=data\n",
    ")\n",
    "\n",
    "# 点击的交互式数据\n",
    "tooltip =[\n",
    "#     ('标题','数据')\n",
    "    (\"\",'@area:@$name')\n",
    "    \n",
    "]\n",
    "# 画布\n",
    "p = figure(\n",
    "    x_range=area, \n",
    "       plot_height=300, \n",
    "       title=\"居民人均可支配收入累计值\",\n",
    "       tooltips=tooltip\n",
    ")\n",
    "p.vbar_stack(time, x='area', width=0.6, color=colors, source=source,\n",
    "             legend=[value(x) for x in time]) \n",
    "\n",
    "# 其他\n",
    "p.y_range.start = 0\n",
    "p.x_range.range_padding = 0.1\n",
    "\n",
    "show(p)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.3"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
